package com.hunlian.makelove.net.api;

import android.content.Context;

import com.google.gson.Gson;
import com.hunlian.makelove.bean.CheckPhoneRegisteredBean;
import com.hunlian.makelove.common.Printout;
import com.hunlian.makelove.net.ServiceInterfaceDef;
import com.hunlian.makelove.net.InterfaceServiceVisit;
import com.hunlian.makelove.net.ResponseCallbackListener;
import com.hunlian.makelove.net.StringResponseCallbackListener;


/**
 * 判断手机号是否注册过
 * @author zealjiang
 * @time 2016年2月20日上午11:40:09
 */
public class CheckPhoneRegisteredServiceVisit extends InterfaceServiceVisit {

	public CheckPhoneRegisteredServiceVisit(Context context) {
		super(context);

		setFunctionId(ServiceInterfaceDef.FUNC_ID_CHECK_PHONE_REGISTERED);
	}

	// 填充参数
	public void setParamters(String phone) {
		paramterData.put("phone", phone);
	}

	public void getResult(final ResponseCallbackListener<CheckPhoneRegisteredBean,Object> listener) {
		doPost(getParamter(), new StringResponseCallbackListener() {
			@Override
			public void onSuccess(String data) {
				Printout.println("手机号是否注册过返回:"+data);
			
				Gson gson = new Gson();
				CheckPhoneRegisteredBean bean = gson.fromJson(data,CheckPhoneRegisteredBean.class);

		        
				if(listener != null){
					listener.onSuccess(bean);
				}
			}

			@Override
			public void onFailure(String errCode, String errMessage,String str) {
				if (listener != null) {
					listener.onFailure(errCode, errMessage,str);
				}
			}
		});
	}


}
